package com.example.demo.server;

import com.example.demo.dao.StuJpaDao;
import com.example.demo.entity.Student;
import org.springframework.cache.annotation.CachePut;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class StuServer {
    @Resource//自动实例化注解
    StuJpaDao stuJpaDao;//学生数据库操作类

    @CachePut(cacheNames = "student", key = "#id")
    public Student go(int id, String name) {
        Student student = stuJpaDao.findById(id).get();
        student.setName(name);
        Student result = stuJpaDao.save(student);
        return result;
    }
}
